package com.qmx.launcher.activity.general;

import android.os.Bundle;
import android.util.Log;

import com.qmx.launcher.R;
import com.qmx.launcher.activity.base.BaseActivity;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class VoiceSetActivity extends BaseActivity {

    //rk3288提供代码
    private static final String exe_path = "su -c system/xbin/cxdish";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_voice_set);
    }


    private StringBuffer execCmd(String icmd) throws IOException {
        String cmd = exe_path + icmd;
        Runtime runtime = Runtime.getRuntime();
        Process process = runtime.exec(cmd);
        InputStream is = process.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        String line = null;
        StringBuffer text = new StringBuffer();
        while (null != (line = br.readLine())) {
            text.append(line + "\n");
            Log.e("########", line);
        }
        try {
            process.waitFor();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return text;
    }

    //todo 需问具体参数和作用
    private StringBuffer setMode(String mSetModeTypeStr) {
        String cmd = " -D /dev/i2c-2 set-mode " + mSetModeTypeStr;
        StringBuffer res = null;
        try {
            res = execCmd(cmd);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return res;
    }
}
